<?php

namespace app\api\controller\carbon\active;

use app\common\controller\Api;
use think\Db;

/**
 * 核算记录接口
 */
class Log extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 活动报名
     *
     */
    public function ent_registration($id)
    {
        $params = array(
            'active_id' => $id,
            'user_id' => $this->auth->id,
            'status' => 1,
            'create_time' => time()
        );
        $add = model('app\admin\model\carbon\active\Log')->insert($params);
        if ($add) {
            $this->success('报名成功');
        }
        $this->error('报名失败');
    }

    /**
     * 活动报名
     *
     */
    public function user_active()
    {
        $list = model('app\admin\model\carbon\active\Log')
            ->where('user_id', $this->auth->id)
            ->paginate();

        $this->success('获取成功', $list);
    }
}
